home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
patches
/
dopus511.lha
/
dopus_pch.lha
/
ARexx.lha
/
Arexx
/
PBar.dopus5
< prev
next >
Wrap
Text File
|
1995-06-09
|
5KB
|
143 lines
/* Progress-Bar v1.02 [13-May-1995] for Directory Opus 5.
By Leo Davidson ("Nudel", P0T-NOoDLE/Gods'Gift Utilities)
This ARexx script will add a progress bar (like when deleting files)
to external commands which are run on all the selected entries in a
lister.
Call as:
------------------------------------------------------------------------------
ARexx PBar.dopus5 {Qp} "<1>" "<2>"
------------------------------------------------------------------------------
Where <1> is the AmigaDOS command to be run for each file.
Insert "!!f!!" (without quotes) where you would like the full path to the
selected file (you can insert it more than once, if you require).
<2> is the progress window title.
If <1> or <2> have any spaces in them, "put quotes around them".
The "Do All Files" switch MUST be turned *_OFF_*!!!
e.g.
------------------------------------------------------------------------------
ARexx DOpus5:ARexx/PBar.dopus5 {Qp} "C:PackIt !!f!! CRUNCH" "Packing files:"
------------------------------------------------------------------------------
Note: The command you use must be able to handle "filenames with quotes".
TO DO:
------
- Make it rescan all selected entries.
(Short of making it rescan the entire dir, which you can do as a switch
within DOpus, I don't think there is a way to emulate "Reload each file"
via an ARexx script, at least in the current version of DOpus5.)
- Perhaps propper support for all the {} type codes, not just {f}.
- ONLY DIRS and ONLY FILES options.
(If you don't want it to act on files or on dirs, simply don't select them!)
- Take a filetype-ID so that only files matching it are acted on.
(this would actually be a pain to impliment - I'm not about to).
*/
/*-- Setup ------------------------------------------------------------------*/
/* You should edit the SepBar below to look right with your output-window
setup (use the script and you'll see what it does). */
SepBar = "
-----------------------------------------------------------------------------------
"
options results
options FAILAT 99
signal on syntax;signal on ioerr /* Error trapping */
/*- Parse the command-line --------------------------------------------------*/
CmdLine = ARG(1)
DOpusPort = GetCmdWord()
UserCommand = GetCmdWord()
UserTitle = GetCmdWord()
If DOpusPort~="" THEN Address value DOpusPort
ELSE Do
Say "Not correctly called from Directory Opus 5!"
Say "Load this ARexx script into editor for more info."
EXIT
END
If UserTitle="" Then UserTitle = "Doing all files..."
lister query source /* Get lister and set busy */
IF RC ~= 0 Then Do
dopus request '"You must have a SOURCE lister!" OK'
EXIT
End
Lister_Handle = RESULT
lister set Lister_Handle busy 1
lister query Lister_Handle numselentries /* Get info about selected */
Lister_NumSelEnt = RESULT /* entries & path to them */
lister query Lister_Handle path
Lister_Path = Strip(RESULT,"B",'"')
If Lister_NumSelEnt = "RESULT" | Lister_Path = "RESULT" Then Do
lister set Lister_Handle busy 0
EXIT
END
/*-- The Progress Bar ---------------------------------------------------------
A progress bar will display how many of the selected files have been done.
This means the max-number argument is Lister_NumSelEnt.
For each selected entry, the "Do i..." loop updates the progress bar,
builds and executes the user-defined command, and then de-selects.
-----------------------------------------------------------------------------*/
lister set Lister_Handle progress Lister_NumSelEnt UserTitle
Do i=1 to Lister_NumSelEnt
lister query Lister_Handle firstsel
Temp_Name = RESULT
lister select Lister_Handle Temp_Name 0
Temp_Name = Strip(Temp_Name,"B",'"')
lister set Lister_Handle progress name Temp_Name
lister set Lister_Handle progress count i
lister query Lister_Handle abort
IF RESULT=1 THEN BREAK /* If they aborted, break the loop */
Temp_Name = '"'||Lister_Path||Temp_Name||'"'
Temp_Exec = Upper(UserCommand)
Do While Index(Temp_Exec,"!!F!!") ~= 0
Temp_Pos = Index(Temp_Exec,"!!F!!")
Temp_Exec = DelStr(Temp_Exec,Temp_Pos,"5")
Temp_Exec = Insert(Temp_Name,Temp_Exec,Temp_Pos-1)
END
Address Command Temp_Exec
Say SepBar
END
/*-- Restore the Lister for normal use --------------------------------------*/
syntax:;ioerr: /* In case of error, jump here */
lister clear Lister_Handle progress
lister refresh Lister_Handle
lister set Lister_Handle busy 0
EXIT
/*- Function for Command-Line parsing -----------------------------------------
ARexx's "PARSE ARG" is rank. It isn't very good at handling arguments with
"quotes" (especially when the quotes are optional), and inserts spaces
where you don't want them sometimes. I don't have the docs to RexxDosSupport,
so I wrote my own function which extracts the next argument from the string
"CmdLine", respecting quotes, and not adding extra spaces at either side.
-----------------------------------------------------------------------------*/
GetCmdWord:
Temp_CmdWord = Word(CmdLine,1)
CmdLine = DelWord(CmdLine,1,1)
If Left(Temp_CmdWord,1) = '"' Then Do Forever
If Right(Temp_CmdWord,1) = '"' Then Break
If Words(CmdLine) = "0" Then Call BadCmd_Quotes
Temp_CmdWord = Temp_CmdWord||" "||Word(CmdLine,1)
CmdLine = DelWord(CmdLine,1,1)
End
Return Strip(Temp_CmdWord,"B",'"')
BadCmd_Quotes:
dopus request '"PBar.dopus5: Bad Command Line.' || X2C(0A) || 'Unclosed quotes in string." OK'
EXIT